﻿using System;
using MessageSystem.Managed.Rpc;
using MessageSystem.Managed.Infrastructure;

namespace MessageSystem.Managed.LuaRpc
{
    class LuaInvoker:RpcInvoker
    {
        public static readonly LuaInvoker Instance = new LuaInvoker();

        public void Invoke(object _interface, RpcSessionService service, ushort flags, short methodid,Int32 OpCode,NetStream stream)
        {

        }

        public void Return(ushort flags, short methodid,Int32 OpCode, NetStream stream, RpcSessionService service)
        {
            LuaMessage response = new LuaMessage();
            response.Read(stream);

            object obj = service.PopCallback(OpCode);
            if (null != obj)
            {
                LuaCallback callback = obj as LuaCallback;
                if (null != callback)
                {
                    callback.Callback(response.Json);
                }
            }
        }
    }
}
